home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9101 / techtip2.jan < prev    next >
Text File  |  1990-11-16  |  2KB  |  45 lines

  1. Listing 2
  2.  
  3. PROC MakeKey(tbl,a)          ; pass the table name and the number
  4.                              ; of key fields
  5.     {Modify} {Restructure}   ; begin the restructure procedure
  6.     TYPEIN tbl ENTER         ; specify table to be restructured
  7.     IF SEARCH("*",[Field Type]) = 0 THEN    ; the table isn't keyed,
  8.                                             ; so key it
  9.          Right Right         ; move to [Field Type]
  10.          i = 1               ; set the fields-keyed counter to 1
  11.          WHILE i <=a         ; as long as the fields-keyed counter
  12.                              ; is less than or equal to the number
  13.                  ; of fields to be keyed,
  14.                              ; perform this loop
  15.              "*" Down        ; make the current field a key field
  16.              i = i + 1       ; increment the fields-keyed counter
  17.          ENDWHILE
  18.          Do_It!              ; when all necessary field are keyed,
  19.                              ; complete the restructure and
  20.          ClearImage          ; remove the table from the workspace
  21.     ELSE                     ; the table is already keyed
  22.          Menu {Cancel}       ; so don't restructure it
  23.     ENDIF
  24.     RELEASE VARS i
  25. ENDPROC
  26.  
  27. PROC UnKey(tbl)              ; pass name of the table to be unkeyed
  28.     {Modify} {Restructure}   ; restructure the table
  29.     TYPEIN tbl Enter         ; specify the table to be unkeyed
  30.     Right Right              ; move to [Field Type]
  31.     IF SEARCH ("*",[Field Type]) <> 0 THEN    ; this table is keyed
  32.          WHILE SEARCH ("*",[Field Type]) <> ) ; as long as current
  33.                                               ; field is keyed
  34.              Backspace Down  ; unkey field and move to next field
  35.          ENDWHILE
  36.          Do_It!              ; complete the restructure
  37.          ClearImage          ; clear the restructured table
  38.                  ; from the workspace
  39.     ELSE                     ; the table isn't keyed already
  40.          Menu {Cancel}       ; cancel the restructure
  41.     ENDIF
  42.     RELEASE VARS tbl
  43. ENDPROC
  44.  
  45.